<!DOCTYPE html>
<html lang="en">
<head>
    <title>策略详情</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="none">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="address=no">
    <meta name="format-detection" content="email=no">
    <link rel="stylesheet" href="<?php echo C('STATIC_SHORT_URL');?>/mobile/css/common.css?v=1.0">
    <link rel="stylesheet" href="<?php echo C('STATIC_SHORT_URL');?>/mobile/css/strategies_detail.css?v=3.3">

</head>
<body style="margin: 0 auto;overflow-x: hidden ")>
<?php if (!isWeixin() && !isApp()) { ?>
<div class="detail_title"  >
    <a href="#" class="arrow_left"></a>策略详情
</div>
<div style="position: fixed ;margin-top: 2.4rem;">
<?php } ?>
<div class="person">
    <div class="person_left">
            <span class="left_picture">
                <img class="img1"   src="<?php echo $data['header_img']; ?>">
            </span>
        <div class="name">
            <p><?php echo $data['user_name']; ?></p>
            <span class="timer"><?php echo date('m月d日 H:i', $data['start_date']); ?></span>
        </div>
        <span class="senior"><?php echo $data['level']; ?></span>
    </div>
    <?php if(!$follow){?>
    <a href="#" class="attention"  ></a>
    <?php } else {?>
    <a href="#" class="attention2"  ></a>
    <?php }?>
</div>
<div class="invest">
    <div class="invest_content">
    <b><?php echo $data['title']; ?></b>
    <div class="div1" >
        <?php echo $data_conf; ?>
    </div></div></div>



<div class="gray"></div>
<div style="width: 100%;font-size: 0.6rem;border-bottom: 1px solid #dedede;padding: 0.5rem 0rem 0.5rem 0.4rem;"><span id="pl"></span>评论 <span id="number">(<?php echo $replay_count;?>)</span></div>
</div>
    <!--第一层-->

<div class="floorParent" style="position: relative " >
    <?php if(!$replay_data) { ?>
    <!--评论为空-->
    <div class="empty">
        <div class=" center">
            <div class="img"></div>
            <div class="text" style="font-size: 0.61rem;color:#d2d2d2;  float:left;height:1.2rem;line-height:1.2rem;" >快来发表你的评论吧~</div>
        </div>
    </div>

    <?php } else { ?>
    <!--评论不为空-->
    <?php foreach($replay_data as $key=>$val) { ?>
    <div class="floor_1" title="<?php echo $val['id'] ?>">
        <div class="fl_up" style="float:left;" >
              <span class="fl_picture"style="float:left;" >
                    <img class="img1" src="<?php echo $val['headimgurl']; ?>">
                </span>
           <div style="float:left;" id="name_date">
                <p id="fl_name" style="font-size: 0.6rem" ><?php echo $val['user_name']; ?></p>
                <span class="fl_timer"><?php echo date('m月d日 H:i', $val['announce_time']); ?></span>
            </div>
        </div>
        <p class="contain">
            <?php echo $val['content']; ?>
        </p>
    </div>
    <?php } ?>
    <?php } ?>
</div>
<div style=" width: 100%;height:2rem; " ></div>
</div>
<!--底部-->
<div id="bottom"  style="background:#f45250 ;" >
    <span class="bo_picture"></span>
    <input type="text" autocomplete="off" autocorrect="off" placeholder="说点什么吧！..." class="what">
    <p  id="bo_right">发表</p>
</div>

</body>
</html>

<script src="<?php echo C('STATIC_SHORT_URL');?>/mobile/js/jquery-1.7.1.js"></script>

<script>
    <!--动态设置文字大小-->
    var iWidth = document.documentElement.clientWidth;
    iWidth = iWidth > 1620 ? 1620 : iWidth;
    document.getElementsByTagName('html')[0].style.fontSize = iWidth / 15 + 'px';



    //解决css中的position:fixed问题
//    function a(){
//        if(document.activeElement.tagName == "INPUT"){
//            $("#bottom ").css({"position": "absolute","bottom":"0"});
//        } else {
//            $("#bottom ").css("position", "fixed");
//        }
//
////        if($(document).height()<$(window).height()){
////            $("#bottom ").css({'position':'fixed','bottom':'0px'});
////            $(document).height($(window).height()+'px');
////        }
////
////
//  }



//     window.onscroll=function(){
//     $(".what  ").css("top",$(window).scrollTop());
//     $("#bottom ").css("top",$(window).scrollTop()+$(window).height());
//     }

//        $("input").on('focus', function () {
//            setTimeout(function () {
//                $("#bottom ").css("position", "static");
//            }, 100);
//        }).on('blur', function () {
//            setTimeout(function () {
//                $("#bottom").css("position", "fixed");
//                // 让滚动条滚动1次
//                window.scroll(0, $(window).scrollTop() + 1);
//            }, 100);
//        });

//
//    window.onscroll=function(){
//
//        $(".what").css("top",$(window).scrollTop());
//
//        $("#bottom").css("top",$(window).scrollTop()+$(window).height());
//
//    }




//    $(window).scroll(function(){
//        // 重点就是下面这一条语句的实现
//        $("#bottom ").css({top: window.innerHeight + window.scrollY - $("#bottom").outerHeight() });
//    });
//    json数据
//    {"code":200,"msg":"\u6210\u529f","result":[{"id":"42","content":" 1231234","uid":"111","announce_time":"09\u670813\u65e5 12:48","user_name":"13918426930","headimgurl":"http:\/\/static5.518yin.com\/mobile\/images\/default_avater.png"},{"id":"41","content":"222","uid":"111","announce_time":"09\u670813\u65e5 12:30","user_name":"13918426930","headimgurl":"http:\/\/static5.518yin.com\/mobile\/images\/default_avater.png"},{"id":"40","content":"12325434534","uid":"111","announce_time":"09\u670813\u65e5 12:26","user_name":"13918426930","headimgurl":"http:\/\/static5.518yin.com\/mobile\/images\/default_avater.png"},{"id":"39","content":"1234345","uid":"111","announce_time":"09\u670813\u65e5 12:26","user_name":"13918426930","headimgurl":"http:\/\/static5.518yin.com\/mobile\/images\/default_avater.png"},{"id":"38","content":"32345345","uid":"111","announce_time":"09\u670813\u65e5 12:26","user_name":"13918426930","headimgurl":"http:\/\/static5.518yin.com\/mobile\/images\/default_avater.png"}]}
//    title="<?php echo $val['id'] ?>"

    /*----------------------页面滚动请求数据------------------------*/
    $(function() {

        var dateUid  = $(".floorParent .floor_1").last().attr("title");//获取最后一个元素的title即id号;
        var alias = '<?php echo $alias?>';
        //滚动加载
        $(document).on('scroll', _scroll = function() {
            var flag = 0; //是否加载到最后一页
            if (checkscrollside()) {
                //满足滚动条件
                scrollAjax(flag);
            };
        });
        //滚动条件
        function checkscrollside() {
            return ($(window).scrollTop() == $(document).height() - $(window).height()) ? true : false; //滚动条滚到底部时触发
            //  return (scrollTop + documentH - lastPinH > 350) ? true : false;//到达指定高度后 返回true，触发waterfall()函数
        }
        //滚动请求Ajax
        function scrollAjax(flag){

            var url = "http://h5.518yin.com/page/paging";
            $.ajax({
                type: 'get',
                url:  url + '?id='+dateUid+"&alias="+alias,//后台url传给的数据
                dataType: 'json',
                timeout: 6000,
                beforeSend: function() {
                    // 禁用按钮防止重复提交
                    $(document).off('scroll', _scroll);
                },
                success: function(data) {
                    console.log(data.code)
                    //数据传递验证成功后执行的操作
                    if (data.code == 200) {//Status Code:200 OK(为Http的状态码的数字值，200 (OK/正常)
                        //200 (SC_OK)的意思是一切正常。一般用于相应GET和POST请求。这个状态码对servlet是缺省的；如果没有调用setStatus方法的话，就会得到200)
                        //ps：大爷的，宝宝一直在好奇code是what?

                        for (var i = 0; i < data.result.length; i++) {
                            var str = "<div class='floor_1'><div class='fl_up' style='float: left '> <span class='fl_picture' style='float: left '><img class='img1' src="+data.result[i].headimgurl+"></span><div style='float:left; margin-top: 0.7rem;margin-left: 0.3rem;' id='name_date '><p id='fl_name'>"+data.result[i].user_name+"</p><span class='fl_timer'>"+data.result[i].announce_time+"</span></div></div><p class='contain'>"+data.result[i].content+"</p></div>";

                            dateUid = data.result[i].id;//???
                            $(".floorParent").append(str);
                        }

                    }else if (data.code != 200) {
                        flag = 1;
                        $('.floorParent').append('<div class="noData">没有更多数据了</div>');

                    }
                },
                complete: function() {
                    if (flag == 1) {
                        $(document).off('scroll', _scroll);//加载完成后就取消执行scroll
                    } else {
                        $(document).on('scroll', _scroll);
                    }
                },
                error: function(jqXHR, textStatus, errrorThrown) {
                    if (errrorThrown == 'Not Found') {
                        console.log('Your requested address is not found.');
                    } else if (textStatus == 'timeout') {
                        console.log('Verify the request timeout, please refresh the page and try again');
                    } else {
                        console.log('Your requested address is not found.');
                    }
                }
            });
        }


        var uid1 = "<?php echo $user['id']; ?>";//获取的是从后台动态的id
        var user_name = "<?php echo $user['user_name']; ?>";
        var headimg = "<?php echo $user['headimgurl']; ?>";


//        var headimg = "http://static5.518yin.com/mobile/images/default_avater.png";

        // 点击发送
        $("#bo_right").on('click', _click = function() {

            var flag = 0;

            var date=new Date();
            var mon=date.getMonth()+1; //获取当前月份
            var da=date.getDate(); //获取当前日
            var h=date.getHours(); //获取小时
            var m=date.getMinutes(); //获取分钟
            strTime=mon+'月'+da+'日  '+h+':'+m;

            var feedContent = $("#bottom input").val();
            console.log(feedContent);

            postAjax(user_name,strTime,flag,feedContent);
        });
        //请求Ajax
        function postAjax(user_name,strTime,flag,feedContent){

            var url = 'http://h5.518yin.com/h5/page/reply';
            $.ajax({
                type: 'get',
                url: url + '?uid='+uid1+"&alias="+alias+"&content="+feedContent,
                dataType: 'json',
                beforeSend: function() {
                    // 禁用按钮防止重复提交
                    $(document).off('click', _click);
                },
                success: function(data) {

                    //数据传递验证成功后执行的操作
                    if (data.code == 200) {
                        // alert(user_name)
                        var str1 = "<div class='floor_1'><div class='fl_up' style='float: left ;' > <span class='fl_picture' style='float: left ' ><img src="+headimg+" class='img1'></span><div style='float:left; margin-top: 0.7rem;margin-left: 0.3rem' id='name_date '><p id='fl_name' style='font-size: 0.6rem;' >"+user_name+"</p><span class='fl_timer'>"+strTime+"</span></div></div><p class='contain'>"+feedContent+"</p></div>";
                        $(".floorParent").prepend(str1);
                        feedContent = $("#bottom input").val("");
                    }
                },
                complete: function() {
                    if (flag == 1) {
                        $(document).off('click', _click);
                    } else {
                        $(document).on('click', _click);
                    }
                },
            });
        };

    });




//    //input为空判断
//    $(function (){
//     $('#bo_right ').on('click',function(){
//     // alert(1);
//     // var null_is=$(".bottom input").val();
//     //console.log(null_is);
//     if($(".bottom input").val("")){
//     $(".bottom input").val("内容不能为空!");
//     $(".bottom input").css('color','red');
//     }
//
//     else{
//
//     $(".bottom input").css('color','black');
//
//     }
//     })
//
//     });

</script>




